FROM node:18.20.7 as build-stage
WORKDIR /app

# Set npm registry to Taobao mirror
RUN npm config set registry https://registry.npmjs.org
COPY . .
RUN npm install --ignore-scripts
RUN npm run docker:postinstall
RUN npm run docker:build

FROM nginx:1.27-alpine
COPY --from=build-stage /app/dist/spa /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf